package org.zeqp.chatAI.minio.put;

import cn.hutool.core.io.IoUtil;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;

public class BatchFilePut   implements Serializable {
    private String fileName;

    private long byteLength;

    private InputStream fileInputStream;




    public InputStream getFileInputStream() {
        return fileInputStream;
    }

    public void setFileInputStream(InputStream fileInputStream) {
        this.fileInputStream = fileInputStream;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }


    public void destroyStream(InputStream inputStream){
        try {
            inputStream.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public long getByteLength() {
        long length = 0;
        if(this.fileInputStream!=null){
            byte[] bytes = IoUtil.readBytes(this.fileInputStream);
            length = bytes.length;
        }
        return length;
    }

    public void setByteLength(long byteLength) {
        this.byteLength = byteLength;
    }
}
